# -*- coding: utf-8 -*-
# @Time    : 2022/3/21 11:50
# @Author  : Zhy
# @Email   : mat_wu@163.com
# @File    : main.py
# @Software: PyCharm
from common.settings.default import Config
from second_flask import create_flask_app
from flask import request, jsonify
from common.utils.mytoken import myjwt

app = create_flask_app(Config)

# @app.before_request
# def before_request():
#     whitelist=['/login','/reg']
#     if request.path not in whitelist:
#         # 获取token
#         try:
#             token = request.headers['Token']
#         except:
#             return jsonify({"code":401,'mes':'您必须携带token'})
#
#         flag = myjwt.check_token(token)
#         # 认证token
#         if flag == False:
#             return jsonify({"code":401,'mes':'您无权访问'})
from flask_mail import Mail, Message

# def send_emails(title,content,emaillist):
#     mail = Mail(app)
#     m = Message(title, sender='zhy2608347593@163.com', recipients=emaillist)
#     m.html = content
#     mail.send(m)
#     return jsonify({'message':'ok'})

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=False)
